﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Csharp结业设计
{
    public partial class Teacher_box1 : Form
    {
        public Teacher_box1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //设置连接字符串
            string ConnectionString = "Data Source =LAPTOP-7I3EOIVU\\SQLEXPRESS ; Initial Catalog = Performance_management_system;" + "Integrated Security = true;";
            DataSet dataset = new DataSet(); //创建数据集
            //创建一个新连接
            SqlConnection conn = new SqlConnection(ConnectionString);
            try
            {
                //创建数据提供者
                SqlDataAdapter DataAdapter = new SqlDataAdapter("SELECT * FROM Student_infor  ", conn);// Where 姓名=
                DataAdapter.Fill(dataset, "Student_infor");
                dataGridView1.DataSource = dataset;
                dataGridView1.DataMember = "Student_infor";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                conn.Close();
                conn.Dispose();
                dataset.Dispose();
            }
        }
    }
}
